// src/entities/server-metric.entity.ts
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
import { Server } from './server.entity';

@Entity('server_metrics')
export class ServerMetric {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => Server, (server) => server.metrics)
  server: Server;

  @Column({ type: 'decimal', precision: 5, scale: 2 })
  cpuUsage: number;

  @Column({ type: 'decimal', precision: 5, scale: 2 })
  memoryUsage: number;

  @Column({ type: 'decimal', precision: 5, scale: 2 })
  diskUsage: number;

  @Column({ type: 'bigint', nullable: true })
  networkIn: number;

  @Column({ type: 'bigint', nullable: true })
  networkOut: number;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  collectedAt: Date;
}
